<%@page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
	String id = request.getParameter("id");
%>
<html>
<head>

<script type="text/javascript">
var listUrl = "order/dailyFlowList.do?id="+ <%=id%>;;
$(document).ready(function() {
	$("#submit-search").click(function() {
		$('#dailyFlow-dg').datagrid({
			queryParams : form2Json("fms")
		}); //点击搜索
	});

	$("#dailyFlow-dg").datagrid({
			loadMsg : '数据加载中....',
			width : '100%',
			url : listUrl,
			nowrap : false,
			striped : true,
			sortOrder : 'desc',
			remoteSort : false,
			rownumbers : true,
            pageSize: 20,
			pagination : true,
			pageList : [ 10, 15, 20, 25 ],
			fitColumns : true,
			frozenColumns : [ [ {
				field : 'id',
				checkbox : true
			}, {
				title : '店铺id',
				field : 'id',
				width : 0,
				hidden : 'true'
			} ] ],
			columns : [ [
					{
						field : 'orderTime',
						title : '日期',
						width : 210,
                        formatter : function(val) {
                            return val.split(" ")[0];
                        }

					},
					{
						field : 'orderNumber',
						title : '订单数量',
						width : 100
					},
					{
						field : 'orderMoney',
						title : '订单总金额',
						width : 100
					},
					{
						field : 'refundSum',
						title : '退款',
						width : 100
					},
					{
						field : 'platformPartion',
						title : '平台分成',
						width : 100
					},
					{
						field : 'sumIncome',
						title : '合计收入',
						width : 100
					},
					{
						field : 'couponDeduction',
						title : '优惠券抵扣',
						width : 100
					},
					/*{
						field : 'poundageTotalMoney',
						title : '汇款手续费',
						width : 100
					},*/
					{
						field : 'platformProfit',
						title : '平台盈亏',
						width : 100
					},
					{
						field : 'transferStauts',
						title : '汇款状态',
						width : 100,
                        formatter : function(val){
                            return transferStauts(val);
                        }
					}
			] ]
		});// end datagrid
	//设置分页控件
	var p = $('#dailyFlow-dg').datagrid('getPager');
	$(p).pagination(
				{
					pageSize : 20,//每页显示的记录条数，默认为10
					pageList : [ 20, 25 ],//可以设置每页记录条数的列表
					beforePageText : '第',//页数文本框前显示的汉字
					afterPageText : '页    共 {pages} 页',
					displayMsg : '当前显示 {from} - {to} 条记录   共 {total} 条记录',
					onBeforeRefresh : function() {
						$(this).pagination('loading');
						$(this).pagination('loaded');
					}
				});//end pagination

	schoolChangeListener();
	}); //end ready

	function info() {
        var rows = $('#dailyFlow-dg').datagrid('getSelections');
        if (rows.length != 1) {
            $.messager.alert('操作提示', "请先选择一条要编辑的信息！");
            return;
        }
        var row = $('#dailyFlow-dg').datagrid('getSelected');
        console.log(row);
        var id=row.id;
        var orderTime = row.orderTime.split(" ")[0].toString();
        var url = "shop/dailyFlowDetails.do?id=" + <%=id%> +"&orderTime="+orderTime;
        $.get(url, row,
            function(data) {
                $("#center").empty();
                $("#center").html(data);
                $.parser.parse($("#center"));
            });
    }

function exportDailyFlow(){
    var pageIndex = $(".pagination-num").val();
    var pageSize = $(".pagination-page-list  option:selected").text();
    var url = "order/exportDailyFlow.do?id=" + <%=id%> + "&pageIndex=" + pageIndex + "&pageSize="+pageSize;
    window.open(url);
}

</script>
</head>
<body>
	<div class="linkbar"><a>店铺管理</a>/<a>店铺信息</a>/<a>每日流水</a></div>
	<div class="clear"></div>
	<div id="dailyFlow-dg" toolbar="#toolbar"></div>
    <div id="toolbar">
	    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="info()">每日流水详情</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="exportDailyFlow()">导出</a>
    </div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="listback('shop/index.do')">返回</a>
	</div>
</body>
</html>